package com.example.adopt.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.adopt.entity.ResStatus;
import com.example.adopt.entity.User;
import com.example.adopt.exception.ServiceException;
import com.example.adopt.mapper.UserMapper;
import com.example.adopt.service.UserService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wjl
 * @since 2024-09-13
 */
@Service
public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
@Resource
UserMapper userMapper;
    @Override
    public User login(User user) {
        String username = user.getUsername();
        String password = user.getPassword();
        QueryWrapper<User> wrapper = new QueryWrapper<>();
        wrapper.eq("password",password);
        wrapper.eq("username",username);
        return userMapper.selectOne(wrapper);
    }

    @Override
    public boolean register(User user) {
        int insert = userMapper.insert(user);
        return insert > 0 ? true : false;
    }


}
